import path from "path";
import {defineConfig} from "vite";
import vue from "@vitejs/plugin-vue";

import Components from "unplugin-vue-components/vite";

const pathSrc = path.resolve(__dirname, "src");

const url: string = "http://localhost:5000";
export default defineConfig({
  resolve: {
    alias: {
      "~/": `${pathSrc}/`,
      "@/": `${pathSrc}/`,
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
      },
    },
  },
  plugins: [
    vue(),
    Components({
      // allow auto load markdown components under `./src/components/`
      extensions: ["vue", "md"],
      // allow auto import and original components used in markdown
      include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
      resolvers: [

      ],
      dts: "src/components.d.ts",
    }),
  ],
  server: {
    port: 8082,
    host: "0.0.0.0",
    proxy: {
      "/icesoft-api": {
        target: url,
        ws: true,
        rewrite: path => path.replace(/^\/icesoft-api/, ""),
        changeOrigin: true,
      },
      "/uploadFiles": {
        target: url,
        ws: true,
        changeOrigin: true,
      },
    },
  },
});
